{% macro construct_function(property, source) %}
File(
     payload = BytesIO({{ source }})
)
{% endmacro %}

{% from "property_templates/property_macros.py.jinja" import construct_template %}

{% macro construct(property, source) %}
{{ construct_template(construct_function, property, source) }}
{% endmacro %}

{% macro check_type_for_construct(property, source) %}isinstance({{ source }}, bytes){% endmacro %}

{% macro transform(property, source, destination, declare_type=True, skip_unset=False) %}
{% if property.required %}
{{ destination }} = {{ source }}.to_tuple()
{% else %}
{% if not skip_unset %}{{ destination }}{% if declare_type %}: {{ property.get_type_string(json=True) }}{% endif %} = UNSET{% endif +%}
if not isinstance({{ source }}, Unset):
    {{ destination }} = {{ source }}.to_tuple()
{% endif %}
{% endmacro %}

{% macro multipart(property, source, name) %}
files.append(({{ name }}, {{ source }}.to_tuple()))
{% endmacro %}
